﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.Entity;
using COM.OA.BLL;
using System.Collections.Generic;

public partial class qs_wenjian_download : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        //string fileName = Request.QueryString["n"];//获取文件名
        int f_id = Int32.Parse(Request.QueryString["id"]);//获取文件的ID
        files fss = filesBLL.Select(f_id);
        string fileName = fss.f_filename;

        System.IO.FileStream fs = null;
        fs = System.IO.File.Open(Server.MapPath(@"../gxxz/upload/" + fileName), System.IO.FileMode.Open);
        byte[] btFile = new byte[fs.Length];
        fs.Read(btFile, 0, Convert.ToInt32(fs.Length));//将文件读到数组中
        fs.Close();
        string strFileName = "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);
        this.Response.AddHeader("Content-disposition", strFileName);
        this.Response.ContentType = "application/octet-staream";
        this.Response.BinaryWrite(btFile);


        //修改此文件的的下载次数
      //  string where = "f_id=" + f_id;
       // IList<files> list = filesBLL.Select(where);
       // files f = list[0];
       // f.f_readdegree += 1;
       
       // filesBLL.Update(f);
        this.Response.End();
    }
}
